module.exports = function printScore(student,studentid){     
    let str = '';
    let sums=0;
    let brr=[];
    for(let itemid of studentid){
        for(let itemobj of student){
            if(itemid === itemobj.id){
                let sum = parseInt(itemobj.score.Math) + parseInt(itemobj.score.Chi) +
                        parseInt(itemobj.score.Eng) + parseInt(itemobj.score.Code);
                let average = (sum / 4).toFixed(1)
                str += `${itemobj.name}|${itemobj.score.Math}|${itemobj.score.Chi}|${itemobj.score.Eng}|${itemobj.score.Code}|${average}|${sum}\n`;
                sums+=sum;
                brr.push(sum);
            }
        }
    }
   let arr=(sums/studentid.length).toFixed(1);
   
   function compute_median(brr) {
       brr.sort((x,y)=>x-y);
        if(brr.length %2 === 0){
            return  ((brr[brr.length/2]+brr[brr.length/2-1])/2).toFixed(1);
        }
        if(brr.length %2 !== 0){
            return  (brr[parseInt(brr.length/2)]).toFixed(1);
        }
    }
    console.log(`姓名|数学|语文|英语|编程|平均分|总分\n`+
    `========================\n`+
        `${str}`+
    `========================\n`+
    `全班总分平均数：${arr}\n`+
    `全班总分中位数：`+ compute_median(brr)+`\n`);
}